package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import util.DBUtil;

public class Rest {
	public static void main(String[] args) {
		Connection con = DBUtil.getConnection();
		Statement st = null;
		ResultSet rs = null;
		String sql = "select id,subjectname,classhour,gradeid from subject order by id desc";
		try {
			st = con.createStatement(ResultSet.CONCUR_READ_ONLY,
					ResultSet.TYPE_SCROLL_INSENSITIVE);
			rs = st.executeQuery(sql);
			rs.next();
			rs.next();
			rs.next();
			rs.next();
			System.out.println("到了第四条：");
			System.out.println(rs.getInt("id") + ","
					+ rs.getString("subjectname"));
			rs.previous();
			rs.previous();
			System.out.println("到了第二条：");
			System.out.println(rs.getInt("id") + ","
					+ rs.getString("subjectname"));
		} catch (SQLException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		} finally {

		}

	}
}
